package com.zhisheng.controller;

import com.zhisheng.pojo.Dept;
import com.zhisheng.service.DeptService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 部门管理Controller
 */
@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;
    @GetMapping("/depts")
    public com.zhisheng.pojo.MyResponseResult<List<Dept>> selectAll(){
        // 参  (无参)
        // 调
        List<Dept> depts = deptService.selectAll();
        // 响
        return com.zhisheng.pojo.MyResponseResult.ok(depts);
    }
    @DeleteMapping("/depts/{id}")
    public com.zhisheng.pojo.MyResponseResult<Object> deleteById(@PathVariable Integer id){
        // 参
        // 调
        int i = deptService.deleteById(id);
        // 响
        return i>=1?com.zhisheng.pojo.MyResponseResult.ok("ok"):com.zhisheng.pojo.MyResponseResult.error("删除失败");
    }
}
